package com.crm.service.impl;

import com.crm.domain.Clue;
import com.crm.domain.ClueRecord;
import com.crm.mapper.ClueMapper;
import com.crm.mapper.ClueRecordMapper;
import com.crm.service.IClueRecordService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClueRecordServiceImpl implements IClueRecordService {

    @Autowired
    private ClueRecordMapper clueRecordMapper;
    @Autowired
    private ClueMapper clueMapper;

    /**
     * 根据clueId查询操作记录
     * @param clueId
     * @return
     */
    @Override
    public List<ClueRecord> listByClueId(Long clueId) {
        return clueRecordMapper.selectByClueId(clueId);
    }

    /**
     * 添加操作记录
     * @param clueRecord
     */
    @Override
    public void add(ClueRecord clueRecord) {
        Clue clue = new Clue();
        BeanUtils.copyProperties(clueRecord,clue);
        clue.setId(clueRecord.getClueId());
        clue.setStatus("2");
        clueMapper.updateById(clue);
        clueRecordMapper.insert(clueRecord);
    }
}
